package com.bytech.admin.biz.controller.friendChain;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bytech.common.biz.entity.base.BaseResult;
import com.bytech.common.biz.entity.friendChain.FriendChain;
import com.bytech.common.biz.entity.friendChain.FriendChainDto;
import com.bytech.common.biz.entity.friendChain.FriendChainQuery;
import com.bytech.common.biz.enums.friendChain.FriendChainAuditStatusEnum;
import com.bytech.common.biz.service.remote.user.RemoteBlogUserService;

/**
 * @Author Zhao
 * @Create 2021/10/8 18:00
 */
@Controller
@RequestMapping("/friendChain")
public class FriendChainController {

    @Resource
    private RemoteBlogUserService remoteBlogUserService;

    @GetMapping("/pageByQuery")
    public String pageFriendChainList(Model model) {
        model.addAttribute("chainStatusList", FriendChainAuditStatusEnum.validValues());
        return "/friendChain/chains";
    }

    @PostMapping("/pageByQuery")
    @ResponseBody
    public BaseResult<Page<FriendChainDto>> pageChainByQuery(FriendChainQuery<FriendChain> query) {
        return remoteBlogUserService.pageFriendChainByQuery(query);
    }

    @PostMapping("/delete")
    @ResponseBody
    public BaseResult<String> deleteChain(String id) {
        return remoteBlogUserService.deleteChain(id);
    }

    @PostMapping("/modifyStatus")
    @ResponseBody
    public BaseResult<String> modifyStatus(FriendChain chain){
        return remoteBlogUserService.modifyChain(chain);
    }
}
